package com.erp.erp_servers.OperationLog.imp;

import com.erp.erp_dao.OperationLog.IOperationLogDAO;
import com.erp.erp_entitys.OperationLog.OperationLogEntity;
import com.erp.erp_entitys.OperationLog.OperationLogEntityExample;
import com.erp.erp_servers.OperationLog.IOperationLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @ClassName ImpOperationLogService
 * @Description TODO
 * @Author songjizhen
 * @Date 2020-06-30 21:37
 * @Version 1.0
 */
@Service
public class ImpOperationLogService implements IOperationLogService {
    @Autowired
    IOperationLogDAO operationLogDAO;

    /**
     * 新增组织机构操作日志
     *
     * @param record
     * @return
     */
    @Override
    public int insertSelective(OperationLogEntity record) {
        return operationLogDAO.insertSelective(record);
    }

    /**
     * 查询组织机构操作日志
     *
     * @param record
     * @return
     */
    @Override
    public List<OperationLogEntity> selectByExample(OperationLogEntity record) {
        OperationLogEntityExample example=new OperationLogEntityExample();
        OperationLogEntityExample.Criteria criteria = example.createCriteria();
        criteria.andCompanyCodeEqualTo(record.getCompanyCode());
        List<OperationLogEntity> operationLogEntities = operationLogDAO.selectByExample(example);
        return operationLogEntities;
    }

    /**
     * 主数据、银行、印章插入日志
     *
     * @param type
     * @param operator
     * @param companyCode
     * @param desc
     * @return
     */
    @Override
    public int insertlog(String type, String operator,  String companyCode, String desc) {
        OperationLogEntity log=new OperationLogEntity();
        log.setCompanyCode(companyCode);
        log.setUpdateTime(new Date());
        log.setOperator(operator);
        log.setType(type);
        log.setDesc(desc);
        return operationLogDAO.insertSelective(log);
    }
}
